Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Creating and Disposing of Time Bases

This section discusses the Movie Toolbox functions your application can use to create and dispose of time bases.

The NewTimeBase function lets you create a new time base. You can use the DisposeTimeBase function to dispose of a time base once you are finished with it.

Time bases rely on either a clock component or another time base for their time source. You can use the SetTimeBaseMasterTimeBase function to cause one time base to be based on another time base. The GetTimeBaseMasterTimeBase allows you to determine the master time base of a given time base.

You can assign a clock component to a time base; that clock then acts as the master clock for the time base. You can use the SetTimeBaseMasterClock function to assign a clock component to a time base. The GetTimeBaseMasterClock function enables you to determine the clock component that is assigned to a time base. You can change the offset between a time base and its time source by calling the SetTimeBaseZero function.

You can set the time source of a movie by calling the SetMovieMasterTimeBase and SetMovieMasterClock functions.

Note
Although most time base functions can be used at interrupt time, several of the Movie Toolbox functions cannot. These functions are noted in the sections that follow.

NewTimeBase

The NewTimeBase function allows your application to obtain a new time base. This function returns a reference to the new time base. Your application must use that reference with other time base functions.

pascal TimeBase NewTimeBase (void);

DESCRIPTION

The NewTimeBase function returns a reference to the new time base.

This function sets the rate of the time base to 0, the start time to its minimum value, the time value to 0, and the stop time to its maximum value.

This function assigns the default clock component to the new time base. If you want to assign a different clock component or a master time base to the new time base, use the SetTimeBaseMasterClock or SetTimeBaseMasterTimeBase functions, which are described on SetTimeBaseMasterClock and SetTimeBaseMasterTimeBase , respectively.

SPECIAL CONSIDERATIONS

The NewTimeBase function uses the Memory Manager, so your application must not call it at interrupt time.

ERROR CODES

None

DisposeTimeBase

The DisposeTimeBase function allows your application to dispose of a time base once you are finished with it.

pascal void DisposeTimeBase (TimeBase tb);
tb
Specifies the time base for this operation. Your application obtains this time base identifier from the NewTimeBase function described in the previous section.

DESCRIPTION

The DisposeTimeBase function cancels and disposes of any pending callback events that are associated with the time base.

SPECIAL CONSIDERATIONS

Note that the DisposeTimeBase function uses the Memory Manager; therefore, you should not call this function at interrupt time.

ERROR CODES

None

SetMovieMasterClock

You can use the SetMovieMasterClock function to assign a clock component to a movie. Do not use the SetTimeBaseMasterClock function to assign a clock component to a movie.

pascal void SetMovieMasterClock (Movie theMovie,
                                         Component clockMeister,
                                         const TimeRecord *slaveZero);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

clockMeister
Specifies the clock component to be assigned to this movie. Your application can obtain this component identifier from the Component Manager's FindNextComponent routine (see the chapter "Component Manager" in Inside Macintosh: More Macintosh Toolbox for more information about this routine).

You can pass in either a component or a component instance for this parameter. If a component is passed, it will be instantiated. If an instance is passed, it will be used. If an instance is passed in, it will not be closed automatically, and remains the responsibility of the software that created it.

slaveZero
Contains a pointer to the time, in the clock's time scale, that corresponds to a 0 time value for the movie. This parameter allows you to set an offset between the clock component and the time base of the movie. Set this parameter to nil if there is no offset.

ERROR CODES

None

SetMovieMasterTimeBase

You can use the SetMovieMasterTimeBase function to assign a master time base to a movie. Do not use the SetTimeBaseMasterTimeBase function (described on SetTimeBaseMasterTimeBase ) to assign a time base to a movie.

pascal void SetMovieMasterTimeBase (Movie theMovie, TimeBase tb,
                                         const TimeRecord *slaveZero);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

tb
Specifies the master time base to be assigned to this movie. Your application obtains this time base identifier from the NewTimeBase function (described on NewTimeBase ).

slaveZero
Contains a pointer to the time, in the time scale of the master time base, that corresponds to a 0 time value for the movie. This parameter allows you to set an offset between the movie and the master time base. Set this parameter to nil if there is no offset.

SPECIAL CONSIDERATIONS

The SetMovieMasterTimeBase function cannot be called at interrupt time.

ERROR CODES

None

SetTimeBaseMasterClock

You can use the SetTimeBaseMasterClock function to assign a clock component to a time base. A time base derives its time from either a clock component or from another time base. Do not use this function to assign a clock to a movie's time base.

pascal void SetTimeBaseMasterClock (TimeBase slave,
                                         Component clockMeister,
                                         const TimeRecord *slaveZero);
slave
Specifies the time base for this operation. Your application obtains this time base identifier from the NewTimeBase function (described on NewTimeBase ).

clockMeister
Specifies the clock component to be assigned to this time base. Your application can obtain this component identifier from the Component Manager's FindNextComponent routine (see the chapter "Component Manager" in Inside Macintosh: More Macintosh Toolbox for more information about this routine).

You can pass in either a component or a component instance for this parameter. If a component is passed, it will be instantiated. If an instance is passed, it will be used. If an instance is passed in, it will not be closed automatically, and remains the responsibility of the software that created it.

slaveZero
Contains a pointer to the time, in the clock's time scale, that corresponds to a 0 time value for the slave time base. This parameter allows you to set an offset between the time base and the clock component. Set this parameter to nil if there is no offset.

SPECIAL CONSIDERATIONS

The SetTimeBaseMasterClock function cannot be called at interrupt time.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SEE ALSO

You can use the GetTimeBaseMasterClock function, which is described in the next section, to determine the clock component that is assigned to a time base.

GetTimeBaseMasterClock

You can use the GetTimeBaseMasterClock function to determine the clock component that is assigned to a time base. A time base derives its time from either a clock component or from another time base. If a time base derives its time from a clock component, you can use this function to obtain the component instance of the clock component.

pascal ComponentInstance GetTimeBaseMasterClock (TimeBase tb);
tb
Specifies the time base for this operation. Your application obtains this time base identifier from the NewTimeBase function (described on NewTimeBase ).

DESCRIPTION

The GetTimeBaseMasterClock function returns a reference to a component instance of the clock component that provides a time source to this time base.

Note
The Component Manager allows a single component to serve multiple client applications at the same time. Each client application has a unique access path to the component. These access paths are called connections. You identify a component connection by specifying a component instance. The Component Manager provides this component instance to your application when you open a connection to a component. The component maintains separate status information for each open connection.

Do not close this connection--the time base is using the connection to maintain its time source. If a clock component is not assigned to the time base, this function sets the returned reference to nil . In this case, the time base relies on another time base for its time source. Use the GetTimeBaseMasterTimeBase function, which is described on GetTimeBaseMasterTimeBase , to obtain the time base reference to that master time base.

ERROR CODES

None

SEE ALSO

You can use the SetTimeBaseMasterClock function, which is described on SetTimeBaseMasterClock , to assign a clock component to a time base.

SetTimeBaseMasterTimeBase

You can use the SetTimeBaseMasterTimeBase function to assign a master time base to a time base. A time base derives its time from either a clock component or another time base. Do not use this function to assign a master time base to a movie's time base.

pascal void SetTimeBaseMasterTimeBase (TimeBase slave,
                                         TimeBase master,
                                         const TimeRecord *slaveZero);
slave
Specifies the time base for this operation. Your application obtains this time base identifier from the NewTimeBase function (described on NewTimeBase ).

master
Specifies the master time base to be assigned to this time base. Your application obtains this time base identifier from the NewTimeBase function.

slaveZero
Contains a pointer to the time, in the time scale of the master time base, that corresponds to a 0 time value for the slave time scale. This parameter allows you to set an offset between the time base and the master time base. Set this parameter to nil if there is no offset.

ERROR CODES

None

SEE ALSO

You can use the GetTimeBaseMasterTimeBase function, which is described in the next section, to determine the master time base that is assigned to a time base.

GetTimeBaseMasterTimeBase

You can use the GetTimeBaseMasterTimeBase function to determine the master time base that is assigned to a time base. A time base derives its time from either a clock component or from another time base. If a time base derives its time from another time base, you can use this function to obtain the identifier for that master time base.

pascal TimeBase GetTimeBaseMasterTimeBase (TimeBase tb);
tb
Specifies the time base for this operation. Your application obtains this time base identifier from the NewTimeBase function (described on NewTimeBase ).

DESCRIPTION

The GetTimeBaseMasterTimeBase function returns a reference to the master time base that provides a time source to this time base. If a master time base is not assigned to the time base, this function sets the returned reference to nil . In this case, the time base relies on a clock component for its time source. Use the GetTimeBaseMasterClock function, which is described on GetTimeBaseMasterClock , to obtain the component instance reference to that clock component.

ERROR CODES

None

SEE ALSO

You can use the SetTimeBaseMasterTimeBase function, which is described in the previous section, to assign a master time base to a time base.

SetTimeBaseZero

You can use the SetTimeBaseZero function to change the offset from a time base to either its master time base or its clock component. You establish the initial offset when you assign the time base to its time source.

pascal void SetTimeBaseZero (TimeBase tb, TimeRecord *zero);
tb
Specifies the time base for this operation. Your application obtains this time base identifier from the NewTimeBase function (described on NewTimeBase ).

zero
Contains a pointer to the time that corresponds to a 0 time value for the slave time scale. This parameter allows you to set an offset between the time base and its time source. Set this parameter to nil if there is no offset.

ERROR CODES

None

SEE ALSO

You can use the SetTimeBaseMasterClock function (described on SetTimeBaseMasterClock ) to assign a time base to a clock component.

You can use the SetTimeBaseMasterTimeBase function (described on SetTimeBaseMasterTimeBase ) to assign a time base to a master time base.


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next